package flst.ipiweb.struts.action.relai;

import ipiwebprocess.relaiProcess;
import ipiwebtransverse.relai;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class RelaiFormulaire extends Action {

	private static relaiProcess sRelaiProcess = new relaiProcess();


	public ActionForward execute(
			ActionMapping mapping, 
			ActionForm form,
			HttpServletRequest request, 
			HttpServletResponse response)
			throws Exception {
		
			RelaiForm vRelaiForm = new RelaiForm();
			
			if ((request.getParameter("id") != null)){
			relai vRelai = sRelaiProcess.GetRelaiById(new Integer(request.getParameter("id")).intValue());
			
			
			vRelaiForm.setIdRelai(vRelai.getIdRelai());
			vRelaiForm.setNumeroRelai(vRelai.getNumeroRelai());
			vRelaiForm.setNomRelai(vRelai.getNomRelai());
			vRelaiForm.setNumeroRueAdresse(vRelai.getAdresse().getNumeroRueAdresse());
			vRelaiForm.setComplementAdresse(vRelai.getAdresse().getComplementAdresse());
			vRelaiForm.setCodePostal(vRelai.getAdresse().getCodePostal());
			vRelaiForm.setVille(vRelai.getAdresse().getVille());
					
			request.setAttribute("relai", vRelaiForm);
			}
			
		return mapping.findForward("relai_formulaire");	
	
}
	
	
}
